package com.rmb.system.controller;

import com.github.pagehelper.PageInfo;
import com.rmb.mart.entity.linxi.RmbSystemStation;
import com.rmb.system.aop.annotation.SystemLog;
import com.rmb.system.aop.enums.LogType;
import com.rmb.system.service.RmbSystemStationService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * (RmbSystemStation)表控制层
 *
 * @author makejava
 * @since 2021-01-20 15:17:37
 */
@RestController
@RequestMapping("rmbSystemStation")
public class RmbSystemStationController {
    /**
     * 服务对象
     */
    @Resource
    private RmbSystemStationService rmbSystemStationService;

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @SystemLog(description = "根据ID查询岗位对象",type = LogType.SELECT)
    @GetMapping("selectOne")
    public RmbSystemStation selectOne(Long id) {
        return this.rmbSystemStationService.queryById(id);
    }

    /**
     * 查询所有岗位
     * @param page 起始页数
     * @param size 条数
     * @return 实例对象
     */
    @SystemLog(description = "查询岗位",type = LogType.SELECT)
    @GetMapping("findList/{page}/{size}")
    public PageInfo<RmbSystemStation> findList(
            @PathVariable("page")int page,
            @PathVariable("size")int size
    ){
        return rmbSystemStationService.findList(page,size);
    }

    /**
     * 添加岗位
     * @param rmbSystemStation 数据
     * @return 是否
     */
    @SystemLog(description = "添加岗位",type = LogType.INSERT)
    @PostMapping("addStation")
    public int addStation(@RequestBody RmbSystemStation rmbSystemStation){
        return rmbSystemStationService.addStation(rmbSystemStation);
    }

    /**
     * 删除岗位
     * @param id 编号
     * @return 是否
     */
    @SystemLog(description = "删除岗位",type = LogType.DELETE)
    @DeleteMapping("delStation/{id}")
    public int delStation(@PathVariable("id")Long id){
        return rmbSystemStationService.delStation(id);
    }

    /**
     * 修改岗位
     * @param rmbSystemStation 数据
     * @return 是否
     */
    @SystemLog(description = "修改岗位信息",type = LogType.UPDATE)
    @PutMapping("updateStation")
    public int updateStation(@RequestBody RmbSystemStation rmbSystemStation){
        return rmbSystemStationService.updateStation(rmbSystemStation);
    }
}